GrapeCity.Win.MultiRow Namespace > GcMultiRow Class > Sort Method : Sort(SortItem[]) Method |
<FeatureAttribute(Name="Sort", Version="v5.0")> Public Overloads Sub Sort( _ ByVal sortItems() As SortItem _ )
Dim instance As GcMultiRow Dim sortItems() As SortItem instance.Sort(sortItems)
Exception | Description |
---|---|
System.ArgumentNullException | The sortItems parameter is a null reference (Nothing in Visual Basic). |
System.ArgumentException | The sortItems array has no items. |
System.InvalidOperationException | This method cannot be accessed when the Template is a null reference (Nothing in Visual Basic). -or- VirtualMode is true and DataSource is a null reference (Nothing in Visual Basic). |
This method can sort multiple columns at the same time by using multiple SortItems.
This method allows advanced customization of the sorting feature in the GcMultiRow class. In order to implement a highly customized sorting operation, write an event handler for the CellMouseClick event for ColumnHeaderCell and call this method with an instance of a class that implements the System.Collections.IComparer interface as a member of SortItem. In this case, you typically set the SortMode property to SortMode.Programmatic to disable automatic sorting and to leave room for a sorting glyph. When sorting by cells set to programmatic sort mode, you must display the sorting glyph yourself by setting the SortGlyphDirection property.
If the AllowUserToAddRows property value is true, the last row is always the last row. In this case, the sorting operator does not effect the last row (uncommitted new row).
void SortByCodeMultiCells() { SortItem sortItem1 = new SortItem(0, SortOrder.Ascending); SortItem sortItem2 = new SortItem(1, SortOrder.Descending); SortItem[] sortItems = new SortItem[] { sortItem1, sortItem2 }; // In one sort operator, sort two cells in all rows by using SortItem. this.gcMultiRow1.Sort(sortItems); }
Private Sub SortByCodeMultiCells() Dim sortItem1 As New SortItem(0, SortOrder.Ascending) Dim sortItem2 As New SortItem(1, SortOrder.Descending) Dim sortItems As SortItem() = New SortItem() {sortItem1, sortItem2} ' In one sort operator, sort two cells in all rows by using SortItem. Me.gcMultiRow1.Sort(sortItems) End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2